package com.angel.sensors.model.types;

import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorEvent;

import com.angel.sensors.R;
import com.angel.sensors.model.HardwareSensorMeter;
import com.angel.sensors.model.MeterType;
import com.angel.sensors.model.NumericComponent;
import com.angel.sensors.model.SensorComponent;
import com.angel.sensors.model.SensorStrings;

public class GyroscopeMeter extends HardwareSensorMeter{

	public GyroscopeMeter(Context context) {
		// TODO Auto-generated constructor stub
		super(context, Sensor.TYPE_GYROSCOPE);
		
		final double min = -2;
        final double max =  2;
		
		 initComponents(new SensorComponent[]{
		            new NumericComponent(SensorStrings.X_COMPONENT, "X", min, max, 3, "uT"),
		            new NumericComponent(SensorStrings.Y_COMPONENT, "Y", min, max, 3, "uT"),
		            new NumericComponent(SensorStrings.Z_COMPONENT, "Z", min, max, 3, "uT")
		        });
	}
	
    @Override
    public int getType() {
        return MeterType.GYROSCOPE;
    }
    
    public String getName() {
        return SensorStrings.GYROSCOPE;
    }
    
    public String getText() {
        return context.getResources().getString(R.string.gyroscope);
    }

    @Override
    public void onSensorChanged(SensorEvent event) {
    	updateNumericValue(SensorStrings.X_COMPONENT, event.values[0]);
        updateNumericValue(SensorStrings.Y_COMPONENT, event.values[1]);
        updateNumericValue(SensorStrings.Z_COMPONENT, event.values[2]);
    }
}
